#pragma once

#include "pcap.h"
#include <thread>

#ifdef CPATUREPKTEXPORT
#define CAPTUREPKTAPI __declspec(dllexport)
#else
#define CAPTUREPKTAPI __declspec(dllimport)
#endif

class CAPTUREPKTAPI CNetworkPacket
{
public:
	CNetworkPacket();
	~CNetworkPacket();

private:
	unsigned char *buffer;
	unsigned int bufferlength;
};

class CAPTUREPKTAPI CapturePktInterface {
public:
	CapturePktInterface() :mPktHandle(NULL), mAdReader(NULL), mThread(NULL), bKeepAlive(false), bInitialized(false){}
	~CapturePktInterface()
	{
		Stop();
	}

	typedef void HandleNetworkPktCallback(CNetworkPacket*pkt);

	bool Initialize(HandleNetworkPktCallback* callback);
	bool Start();
	void Stop();

private:
	HandleNetworkPktCallback* mPktHandle;
	pcap_t * mAdReader;
	std::thread* mThread;
	bool bKeepAlive;
	bool bInitialized;


	static void ThreadFunc(void* arg);
};